<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/vue.js"></script>
    <script src="js/axios.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.zhimg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.zhimg.com/element-ui/lib/index.js"></script>

</head>
<body>
<div id="app">
    <el-row>
        <el-col :lg="24" >
            <el-card class="box-card" >
                <el-row>
                    <el-col>
                        <div style="margin: 20px 0">
                            <el-button type="primary" icon="el-icon-plus" style="margin-bottom: 10px; border-radius: 0px;">返回</el-button>
                            <el-input v-model="typeName" placeholder="请输入要添加的类型名称" clearable style="width: 200px"></el-input>
                            <el-button type="primary" style="margin-bottom: 10px; border-radius: 0px;">添加主节点类型</el-button>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col>
                        <div style="margin: 20px 0">
                            <el-input v-model="filterText" placeholder="请输入关键字进行搜索" clearable style="width: 200px"></el-input>
                        </div>
                        <div style="margin: 20px 0">
                            <el-tree
                                    class="filter-tree"
                                    :data="data"
                                    :props="defaultProps"
                                    default-expand-all
                                    @node-click="handleNodeClick"
                                    :filter-node-method="filterNode"
                                    ref="tree">
                            </el-tree>
                        </div>
                    </el-col>
                </el-row>
            </el-card>
        </el-col>
    </el-row>
</div>
<script>
    new Vue({
        el:"#app",
        data:{
            typeName:"",
            filterText:'',
            data: [],
            defaultProps: {
                children: 'children',
                label: 'label'
            },
        },
        mounted(){
            axios.get("/qb/menu").then(res=>{
                this.data=res.data;
                console.log(res);
            })
        },
        watch:{
            filterText(val) {
                this.$refs.tree.filter(val);
            }
        },
        methods: {
            handleNodeClick(data) {
                console.log(data);
            },
            filterNode(value, data) {
                console.log(value);
                console.log(data)
                if (!value) return true;
                return data.label.indexOf(value) !== -1;
            }
        }
    })
</script>
</body>
</html>